
#pragma once

#include <ttg/math.h>
#include <ttg/services.h>

//Serial version of Pi calculation (using Monte-Carlo method).
double serialPi(int throw_count)
{
	int hits = 0;
	srand((int)ttg::services::Timer::getRef()->getMilliSeconds());
	for (int i = 0; i < throw_count; i++)
	{
		double x = ttg::math::getFloatRandom(-1.0f, 1.0f);
		double y = ttg::math::getFloatRandom(-1.0f, 1.0f);
		if (x * x + y * y <= 1.0)
			hits++;
	}
	return (4.0 * hits) / throw_count;
}
